﻿<Window x:Class="Convertor.ConfigWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Convertor"
        xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
        xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:control="clr-namespace:Wpf.CommonTools.PseronalControl;assembly=Wpf.CommonTools"
        xmlns:Valid="clr-namespace:Convertor.Code.Validation"
        Icon="Images/Setting.png"
        Title="{DynamicResource ApplicationSetting}"
        TextOptions.TextFormattingMode="Display"
        MinHeight="300" MinWidth="500"
        KeyDown="Window_KeyDown"
        KeyUp="Window_KeyUp" SizeToContent="WidthAndHeight">
    <Window.Resources>
        <ObjectDataProvider x:Key="UpdateIntervalTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="local:UpdateIntervalTypes"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <conv:FindUILanguageConverter x:Key="FindUILanguageConverter"/>
        <Style x:Key="ItemMargin" TargetType="DockPanel">
            <Setter Property="Margin" Value="0,-10,0,10"/>
        </Style>
    </Window.Resources>
    <Window.Background>
        <ImageBrush ImageSource="Images/Bg-1.png"/>
    </Window.Background>
    <Grid Background="{StaticResource MainBackgroundOpacityMask}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition  Height="35"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="1" DockPanel.Dock="Top" Style="{StaticResource WhiteMask}">
            <WrapPanel HorizontalAlignment="Right" VerticalAlignment="Top">
                <Button Click="Button_Reset_Click" Padding="14,3,14,3" Template="{DynamicResource ButtonWithoutBackground}">
                    <Button.Content>
                        <WrapPanel>
                            <Image Source="Images/Setting.png" Margin="0,0,3,0" Width="16"/>
                            <TextBlock Text="{DynamicResource Reset}"/>
                        </WrapPanel>
                    </Button.Content>
                </Button>
            </WrapPanel>
        </Border>
        <DockPanel Margin="5,5,5,5" Grid.Row="0" Background="#88F5F3F3">
            <GroupBox Header="{DynamicResource ConvertSetting}" DockPanel.Dock="Top" Style="{StaticResource GroupBoxShadowStyle}">
                <DockPanel Style="{StaticResource ItemMargin}">
                    <CheckBox DockPanel.Dock="Top"
                              Content="{DynamicResource Config_SavedToClipboard}" 
                              IsChecked="{Binding Source={x:Static local:Config.GlobalConfig}, Path=OutputToClipboard}"/>
                    <CheckBox DockPanel.Dock="Top"
                              Content="{DynamicResource Config_AutomaticOutput}" 
                              IsChecked="{Binding Source={x:Static local:Config.GlobalConfig}, Path=AutoOutput}"/>
                    <CheckBox DockPanel.Dock="Top"
                              Content="{DynamicResource Config_IgnoreLog}" 
                              IsChecked="{Binding Source={x:Static local:Config.GlobalConfig}, Path=IgnoreLog}"/>
                    <CheckBox DockPanel.Dock="Top"
                              Content="{DynamicResource Config_UseWebExplorer}" 
                              IsChecked="{Binding Source={x:Static local:Config.GlobalConfig}, Path=UseWebExplorer}"/>
                </DockPanel>
            </GroupBox>
            <GroupBox Header="{DynamicResource Config_WorkPath}" DockPanel.Dock="Top"
                      Margin="0,10,0,0" Style="{StaticResource GroupBoxShadowStyle}">
                <DockPanel Style="{StaticResource ItemMargin}">
                    <DockPanel DockPanel.Dock="Top">
                        <Button Content="..." Template="{StaticResource ButtonWithoutBackground}" DockPanel.Dock="Right" Width="20" Padding="0" Click="Button_WorkPath_Click" />
                        <ComboBox IsEditable="True"
                                  ItemsSource="{Binding Source={ x:Static local:Config.GlobalConfig}, Path=WorkspacePathList}">
                            <ComboBox.Text>
                                <Binding Path="WorkspacePath" Source="{x:Static local:Config.GlobalConfig}" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
                                    <Binding.ValidationRules>
                                        <Valid:WorkSpacePathRule/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </ComboBox.Text>
                        </ComboBox>
                    </DockPanel>
                </DockPanel>
            </GroupBox>
            <GroupBox Header="{DynamicResource ApplicationSetting}" DockPanel.Dock="Top" 
                      Margin="0,10,0,0" Style="{StaticResource GroupBoxShadowStyle}">
                <DockPanel Style="{StaticResource ItemMargin}">
                    <CheckBox DockPanel.Dock="Top"
                              Content="{DynamicResource Config_EnableEscToCloseChildWindows}" 
                              IsChecked="{Binding Source={x:Static local:Config.GlobalConfig}, Path=EnableEscToCloseChildWindows}"/>
                </DockPanel>
            </GroupBox>
            <GroupBox Header="{DynamicResource Config_UpdateIntveralTypes}" DockPanel.Dock="Top" 
                      Margin="0,10,0,0" Style="{StaticResource GroupBoxShadowStyle}">
                <DockPanel Style="{StaticResource ItemMargin}">
                    <AdornerDecorator DockPanel.Dock="Top">
                        <ComboBox ItemsSource="{Binding Source={StaticResource UpdateIntervalTypes}}"
                          SelectedItem="{Binding Source={x:Static local:Config.GlobalConfig}, Path=CheckUpdateInterval}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Config_UpdateIntveralType_'}"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                            <sm:WatermarkService.Titlemark>
                                <TextBlock Text="{DynamicResource Config_UpdateIntveralTypes}" TextAlignment="Right"/>
                            </sm:WatermarkService.Titlemark>
                        </ComboBox>
                    </AdornerDecorator>
                    <TextBlock Text="{Binding Source={x:Static local:Config.GlobalConfig}, Path=LastCheckedUpdate, Converter={StaticResource StringFormatConverter}, ConverterParameter='LastUpdateTime'}" Foreground="Gray" Margin="0,5,5,0" HorizontalAlignment="Right"></TextBlock>
                </DockPanel>
            </GroupBox>
        </DockPanel>
    </Grid>
</Window>
